<?php

namespace App\Console\Commands;

use Carbon\Carbon;
use Illuminate\Console\Command;
use App\Models\Log\PlayerBetFlow;

class ClearBet extends Command
{
    /**
     * The name and signature of the console command.
     *
     * @var string
     */
    protected $signature = 'clear:bet';
    //保存几个月份得数据，从当前月份算起
    protected $saveMonth = '1';
    /**
     * The console command description.
     *
     * @var string
     */
    protected $description = 'Command description';

    /**
     * Create a new command instance.
     *
     * @return void
     */
    public function __construct()
    {
        parent::__construct();
    }

    /**
     * Execute the console command.
     *
     * @return mixed
     */
    public function handle()
    {
//        $now = Carbon::now();
//        $ClearBetStartDay = (clone $now)->subMonth($this->saveMonth)->startOfMonth()->format('Y-m-d H:i:s');
//        $ClearBetEndDay = (clone $now)->subMonth($this->saveMonth)->endOfMonth()->format('Y-m-d H:i:s');
//
//        PlayerBetFlow::where([
//                ['bet_time', '>=', $ClearBetStartDay],
//                ['bet_time', '<=', $ClearBetEndDay],
//            ]
//        )->delete();
        $now = Carbon::now();
        $ClearBetEndDay = (clone $now)->subMonth($this->saveMonth)->endOfMonth()->format('Y-m-d H:i:s');
        PlayerBetFlow::where([
                ['bet_time', '<', $ClearBetEndDay],
            ]
        )->delete();


    }


}
